package com.sakura.oj.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sakura.oj.mapper.ProblemSolutionMapper;
import com.sakura.oj.model.dto.solution.SolutionQueryRequest;
import com.sakura.oj.model.entity.ProblemSolution;
import com.sakura.oj.model.vo.ProblemSolutionVo;
import com.sakura.oj.model.vo.RecentlySolutionVo;
import com.sakura.oj.service.ProblemSolutionService;
import com.sakura.oj.utils.UserHolder;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;


@Slf4j
@Service
@RequiredArgsConstructor
public class ProblemSolutionServiceImpl extends ServiceImpl<ProblemSolutionMapper, ProblemSolution> implements ProblemSolutionService {

    private final ProblemSolutionMapper problemSolutionMapper;

    @Override
    public Page<ProblemSolutionVo> listProblemSolutionVoByPage(SolutionQueryRequest solutionQueryRequest, Page<ProblemSolutionVo> page) {
        return problemSolutionMapper.listProblemSolutionVoByPage(page, solutionQueryRequest);
    }

    @Override
    public List<RecentlySolutionVo> getRecentlySolutionList() {
        Long userId = UserHolder.getUserId();
        return problemSolutionMapper.getRecentlySolutionList(userId);
    }
}
